package net.lab1024.sa.admin.module.business.amazon.controller;

import net.lab1024.sa.admin.module.business.amazon.domain.form.AmazonTaskAddForm;
import net.lab1024.sa.admin.module.business.amazon.domain.form.AmazonTaskQueryForm;
import net.lab1024.sa.admin.module.business.amazon.domain.form.AmazonTaskUpdateForm;
import net.lab1024.sa.admin.module.business.amazon.domain.vo.AmazonTaskVO;
import net.lab1024.sa.admin.module.business.amazon.service.AmazonTaskService;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import cn.dev33.satoken.annotation.SaCheckPermission;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 亚马逊采集任务表 Controller
 *
 * @Author 秦泽鹏
 * @Date 2025-11-03 20:34:57
 * @Copyright 秦泽鹏
 */

@RestController
@Tag(name = "亚马逊采集任务表")
public class AmazonTaskController {

    @Resource
    private AmazonTaskService amazonTaskService;

    @Operation(summary = "分页查询 @author 秦泽鹏")
    @PostMapping("/amazonTask/queryPage")
    @SaCheckPermission("amazonTask:query")
    public ResponseDTO<PageResult<AmazonTaskVO>> queryPage(@RequestBody @Valid AmazonTaskQueryForm queryForm) {
        return ResponseDTO.ok(amazonTaskService.queryPage(queryForm));
    }

    @Operation(summary = "添加 @author 秦泽鹏")
    @PostMapping("/amazonTask/add")
    @SaCheckPermission("amazonTask:add")
    public ResponseDTO<String> add(@RequestBody @Valid AmazonTaskAddForm addForm) {
        return amazonTaskService.add(addForm);
    }

    @Operation(summary = "更新 @author 秦泽鹏")
    @PostMapping("/amazonTask/update")
    @SaCheckPermission("amazonTask:update")
    public ResponseDTO<String> update(@RequestBody @Valid AmazonTaskUpdateForm updateForm) {
        return amazonTaskService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author 秦泽鹏")
    @PostMapping("/amazonTask/batchDelete")
    @SaCheckPermission("amazonTask:delete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
        return amazonTaskService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author 秦泽鹏")
    @GetMapping("/amazonTask/delete/{id}")
    @SaCheckPermission("amazonTask:delete")
    public ResponseDTO<String> batchDelete(@PathVariable Long id) {
        return amazonTaskService.delete(id);
    }
}
